perm filename CIRCU1[F86,JMC] blob sn#826480 filedate 1986-10-15 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	%circu1[f86,jmc]	Sterling,Shapiro circuit program with negation
C00004 ENDMK
CāŠ—;
%circu1[f86,jmc]	Sterling,Shapiro circuit program with negation

inverter(inv(T,R),Input,Output) :-
transistor(T,Input,ground,Output),
resistor(R,power,Output).

nand-gate(nand(T1,T2,R),Input1,Input2,Output) :-
transistor(T1,Input1,X,Output),
transistor(T2,Input2,ground,X),
resistor(R,power,Output),
\+ bad(X,T1,T2).

bad(X,T1,T2) :- node-of(Y,X),\+ Y = T1,\+ Y = T2.

and-gate(and(N,1),Input1,Input2,Output) :-
nand-gate(N,Input1,Input2,X),
inverter(I,X,Output).

node-of(R,N) :- resistor(R,N,Y).
node-of(R,N) :- resistor(R,Y,N).

node-of(R,N) :- transistor(R,N,X,Y).
node-of(R,N) :- transistor(R,X,N,Y).
node-of(R,N) :- transistor(R,X,Y,N).

test1 :- [gdcirc],and-gate(G,n3,n5,n1).
test2 :- [badcrc],and-gate(G,n3,n5,n1).